package model;

import java.io.Serializable;

import javax.persistence.*;

import dtos.ExcursionPersTPDTO;

import java.util.Date;


/**
 * The persistent class for the excursionPersTP database table.
 * 
 */
@Entity
@NamedQuery(name="ExcursionPersTP.findAll", query="SELECT e FROM ExcursionPersTP e")
public class ExcursionPersTP implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	private int excursionPersID;

	@Temporal(TemporalType.TIMESTAMP)
	private Date date;

	//bi-directional many-to-one association to Excursion
	@ManyToOne(cascade={CascadeType.PERSIST})
	@JoinColumn(name="excursionID")
	private Excursion excursion;

	//bi-directional many-to-one association to PersonalizedTP
	@ManyToOne()
	@JoinColumn(name="travelID")
	private PersonalizedTP personalizedTp;

	public ExcursionPersTP() {
	}
	
	public ExcursionPersTPDTO getDTO(){
		 ExcursionPersTPDTO e = new  ExcursionPersTPDTO();
		 e.setDate(this.date);
		 e.setExcursion(this.excursion.getDTOWithoutExcursionPersTP());
		 e.setExcursionPersID(this.excursionPersID);
		 e.setPersonalizedTp(this.personalizedTp.getDTOWithoutExcursionPersTP());
		 return e;
	}

	public int getExcursionPersID() {
		return this.excursionPersID;
	}

	public void setExcursionPersID(int excursionPersID) {
		this.excursionPersID = excursionPersID;
	}

	public Date getDate() {
		return this.date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public Excursion getExcursion() {
		return this.excursion;
	}

	public void setExcursion(Excursion excursion) {
		this.excursion = excursion;
	}

	public PersonalizedTP getPersonalizedTp() {
		return this.personalizedTp;
	}

	public void setPersonalizedTp(PersonalizedTP personalizedTp) {
		this.personalizedTp = personalizedTp;
	}

	public boolean isInPersonalizedTP(int travelID) {
		
		return (this.personalizedTp.getTravelID() == travelID);
	}



}